## first nb to gra:
if(require("spdep")) {
example(columbus)
colNb <- poly2nb(columbus)
## ... here manual editing is possible ...
## then export to graph format
colGra <- nb2gra(colNb)
## and save in BayesX file
graFile <- tempfile()
write.gra(colGra, file=graFile)
## now back from gra to nb:
colGra <- read.gra(graFile)
newColNb <- gra2nb(colGra)
newColNb
## compare this with the original
colNb
## only the call attribute does not match (which is OK):
all.equal(newColNb, colNb, check.attributes = FALSE)
attr(newColNb, "call")
attr(colNb, "call")
}Run the code above in your browser using DataLab